/**
 * 
 * 客户的基本信息
 *  *2010-3-6 下午04:25:28  add 
 */
package com.base.myproject.client.busi.ccode;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.ui.BaseFormPanel;
import com.base.myproject.client.ui.BaseGrid;
import com.base.myproject.client.ui.celleditor.BaseCheckGroup;
import com.extjs.gxt.ui.client.Style.Direction;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.fx.FxConfig;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Label;

/**
 * @author Administrator 2010-3-6 javazgw@gmail.com
 */
public class CcodeMain extends LayoutContainer implements ClickHandler {
	final String title = "基本信息";
	LayoutContainer mainpanel = new LayoutContainer();

	boolean isdetailvisible = false; // 内容只能被增加一次
	BaseStore<BusiObject> presentstore;
	BaseStore<BusiObject> store;
	BaseGrid<BusiObject> grid;
	int height = 400;
	int width = 620;

	public CcodeMain(BaseStore<BusiObject> store) {
		Anchor anchor = new Anchor(title);
		anchor.addClickHandler(this);
		this.setStore(store);
		this.add(anchor);
		this.add(mainpanel);
		mainpanel.setVisible(true);
		mainpanel.setBorders(true);
		initCCodeMain();
	}

	@Override
	public void onClick(ClickEvent event) {
		
		if (mainpanel.isVisible()) {

			mainpanel.el().slideOut(Direction.UP, FxConfig.NONE);
		} else {

			mainpanel.setVisible(true);
			mainpanel.el().slideIn(Direction.DOWN, FxConfig.NONE);
		}

	}

	public void initCCodeMain() {
		if (!isdetailvisible) {
			// mainpanel.add(new Button("ss"));
			// mainpanel.layout();
			initInnerWidget();
			isdetailvisible = true;
		}
	}

	private void initInnerWidget() {
		// ServiceItemPanel tb3 = new ServiceItemPanel();
	
		

		//mainpanel.add(grid);
		mainpanel.add(createForm());
		mainpanel.layout();
	}


	


	

	BaseFormPanel form = null;

	BaseFormPanel createForm() {
		 form = new BaseFormPanel(getStore());
		TableLayout tl = new TableLayout(4);

		TableData td = new TableData();
		td.setRowspan(1);
		td.setHorizontalAlign(HorizontalAlignment.LEFT);
		td.setVerticalAlign(VerticalAlignment.TOP);
		td.setPadding(2);
		td.setWidth("230");
		form.setLayout(tl);
		form.setHeaderVisible(false);

//		form.add(new Label("icode:"), td);
//		NumberField C_num1 = new NumberField();
//		C_num1.setPropertyEditorType(Long.class);
//		C_num1.setName("icode");
//		form.add(C_num1, td);
		form.add(new Label("供应商编码:"), td);
		TextField<String> C_num2 = new TextField<String>();
		C_num2.setAllowBlank(false);
		C_num2.setName("ccode");
		form.add(C_num2, td);
		form.add(new Label("供应商名:"), td);
		TextField<String> C_num3 = new TextField<String>();
		C_num3.setAllowBlank(false);
		C_num3.setName("cname");
		form.add(C_num3, td);
		form.add(new Label("主页地址:"), td);
		TextField<String> C_num4 = new TextField<String>();
		C_num4.setName("httpurl");
		form.add(C_num4, td);
		form.add(new Label("注册资本:"), td);
		TextField<String> C_num5 = new TextField<String>();
		C_num5.setName("registercapital");
		form.add(C_num5, td);
		form.add(new Label("雇员人数:"), td);
		TextField<String> C_num6 = new TextField<String>();
		C_num6.setName("employeenum");
		form.add(C_num6, td);
		form.add(new Label("分支机构数:"), td);
		TextField<String> C_num7 = new TextField<String>();
		C_num7.setName("branchorgnum");
		form.add(C_num7, td);
		form.add(new Label("法人代表:"), td);
		TextField<String> C_num8 = new TextField<String>();
		C_num8.setName("artperson");
		form.add(C_num8, td);
//		form.add(new Label("税  则  号:"), td);
//		TextField<String> C_num9 = new TextField<String>();
//		C_num9.setName("taxno");
//		form.add(C_num9, td);
		form.add(new Label("合伙人:"), td);
		TextField<String> C_num10 = new TextField<String>();

		C_num10.setName("partner");
		form.add(C_num10, td);
		form.add(new Label("企业代码:"), td);
		TextField<String> C_num11 = new TextField<String>();
		C_num11.setName("artno");
		form.add(C_num11, td);
		/*form.add(new Label("createbcode:"), td);
		TextField<String> C_num12 = new TextField<String>();
		C_num12.setName("createbcode");
		form.add(C_num12, td);
		form.add(new Label("createdate:"), td);
		DateField C_data13 = new DateField();
		C_data13.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-M-d"));
		C_data13.setName("createdate");
		form.add(C_data13, td);
		form.add(new Label("updatedate:"), td);
		DateField C_data14 = new DateField();
		C_data14.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-M-d"));
		C_data14.setName("updatedate");
		form.add(C_data14, td);
		form.add(new Label("updatebcode:"), td);
		TextField<String> C_num15 = new TextField<String>();
		C_num15.setName("updatebcode");
		form.add(C_num15, td);*/
//		form.add(new Label("ccodetype:"), td);
//		NumberField C_num16 = new NumberField();
//		C_num16.setPropertyEditorType(Integer.class);
//		C_num16.setName("ccodetype");
//		form.add(C_num16, td);
		form.add(new Label("ccodetype:"), td);
		BaseCheckGroup C_num16 = new BaseCheckGroup(new String[]{"客户","供应商","同行"});
		C_num16.setName("ccodetype");
		form.add(C_num16, td);
		form.inited();
		return form;
	}

	public BaseStore<BusiObject> getStore() {
		return store;
	}

	public void setStore(BaseStore<BusiObject> store) {
		this.store = store;
	};
	
	public boolean isValid()
	{
		return form.isValid();
	}
}
